package com.company.cloud.sdk.weixin.common.exception;

import com.company.cloud.sdk.weixin.common.constant.WxErrorEnum;
import lombok.Getter;

@Getter
public class WxException extends RuntimeException {

    /**
     * 错误码
     */
    private String code = "500";
    /**
     * 错误信息
     */
    private String msg;
    /**
     * 其他额外信息
     */
    private String extra;


    public WxException(String msg) {
        super(msg);
        this.msg = msg;
    }

    public WxException(String msg, Throwable e) {
        super(msg, e);
        this.msg = msg;
    }

    public WxException(WxErrorEnum error) {
        super(error.getMsg());
        this.msg = error.getMsg();
        this.code = error.getCode();
    }

    public WxException(String code, String msg) {
        super(msg);
        this.msg = msg;
        this.code = code;
    }

    public WxException(Integer code, String msg) {
        super(msg);
        this.msg = msg;
        this.code = code == null ? "-100" : code.toString();
    }

    public WxException(String code, String msg, Throwable e) {
        super(msg, e);
        this.msg = msg;
        this.code = code;
    }

    public WxException(String code, String msg, String extra) {
        super(msg);
        this.msg = msg;
        this.code = code;
        this.extra = extra;
    }


}
